﻿using UnityEngine;
using System.Collections;

public class AdminPanel : MonoBehaviour 
{
	public Server server;

	// data
	string question = "";
	string answers = ""; // JSON of answers (todo: make it more user-friendly)
	bool showResults = false;

	int wLeft = 200;
	int wRight = 500;


	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnGUI()
	{
		Rect r = new Rect(5, 5, wLeft, 40);

		GUI.Label(r, "QUESTION:");
		r.x += wLeft;
		r.width = wRight;
		question = GUI.TextField(r, question);

		r = new Rect(5, r.y + r.height + 5, wLeft, 200);
		GUI.Label(r, "ANSWERS:");
		r.x += wLeft;
		r.width = wRight;
		answers = GUI.TextArea(r, answers);

		r = new Rect(5, r.y + r.height + 5, wLeft, 40);

		if (GUI.Button(r, "ADD QUESTION"))
		{
			showResults = false;
			server.AddNewQuestion(question, answers);
		}

		r.x += wRight;
		bool showResultsNow = GUI.Toggle(r, showResults, "SHOW RESULTS");
		if (showResults != showResultsNow)
			server.StartResults(showResultsNow);
		showResults = showResultsNow;

	}
}
